<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns:MSHelp="http://www.microsoft.com/MSHelp/" lang="en-us" xml:lang="en-us"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta name="DC.Type" content="reference">
<meta name="DC.Title" content="memory_pool Template Class">
<meta name="DC.subject" content="memory_pool Template Class">
<meta name="keywords" content="memory_pool Template Class">
<meta name="DC.Relation" scheme="URI" content="../../../../reference/appendices/community_preview_features/scalable_memory_pools.htm">
<meta name="DC.Format" content="XHTML">
<meta name="DC.Identifier" content="memory_pool_cls">
<meta name="DC.Language" content="en-US">
<link rel="stylesheet" type="text/css" href="../../../../intel_css_styles.css">
<title>memory_pool Template Class</title>
<xml>
<MSHelp:Attr Name="DocSet" Value="Intel"></MSHelp:Attr>
<MSHelp:Attr Name="Locale" Value="kbEnglish"></MSHelp:Attr>
<MSHelp:Attr Name="TopicType" Value="kbReference"></MSHelp:Attr>
</xml>
</head>
<body id="memory_pool_cls">
 <!-- ==============(Start:NavScript)================= -->
 <script src="..\..\..\..\NavScript.js" language="JavaScript1.2" type="text/javascript"></script>
 <script language="JavaScript1.2" type="text/javascript">WriteNavLink(4);</script>
 <!-- ==============(End:NavScript)================= -->
<a name="memory_pool_cls"><!-- --></a>

 
  <h1 class="topictitle1">memory_pool Template Class</h1>
 
   
  <div> 
	 <div class="section"><h2 class="sectiontitle">Summary</h2> 
		 
		<p>Template class for scalable memory allocation from
		  memory blocks provided by an underlying allocator. 
		</p>
 
		<div class="Note"><h3 class="NoteTipHead">
					Caution</h3> 
		  <p>If the underlying allocator refers to another
			 scalable memory pool, the inner pool (or pools) must be destroyed before the
			 outer pool is destroyed or recycled. 
		  </p>
 
		</div> 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Syntax</h2> 
		 
		<pre>template &lt;typename Alloc&gt; class memory_pool;</pre> 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Header</h2> 
		 
		<pre>#define TBB_PREVIEW_MEMORY_POOL 1
 #include "tbb/memory_pool.h"</pre> 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Description</h2> 
		 
		<p>A 
		  <samp class="codeph">memory_pool</samp> allocates
		  and frees memory in a way that scales with the number of processors. The memory
		  is obtained as big chunks from an underlying allocator specified by the
		  template argument. The latter must satisfy the subset of requirements described
		  in Table 29 with 
		  <samp class="codeph">allocate</samp>, 
		  <samp class="codeph">deallocate</samp>, and 
		  <samp class="codeph">value_type</samp> valid for 
		  <samp class="codeph">sizeof(value_type)&gt;0</samp>. A 
		  <samp class="codeph">memory_pool</samp> models the
		  Memory Pool concept described in Table 52. 
		</p>
 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Example</h2> 
		 
		<pre>#define TBB_PREVIEW_MEMORY_POOL 1
 #include "tbb/memory_pool.h"
 ...
 tbb::memory_pool&lt;std::allocator&lt;char&gt; &gt; my_pool;
 void* my_ptr = my_pool.malloc(10);
 my_pool.free(my_ptr);</pre> 
		<p>The code above provides a simple example of
		  allocation from an extensible memory pool. 
		</p>
 
	 </div>
 
	 <div class="section"><h2 class="sectiontitle">Members</h2> 
		 
		<pre>namespace tbb {
 template &lt;typename Alloc&gt;
 class memory_pool : no_copy {
 public:
 memory_pool(const Alloc &amp;src = Alloc()) throw(std::bad_alloc);
 ~memory_pool();
 void recycle();
 void *malloc(size_t size);
 void free(void* ptr);
 void *realloc(void* ptr, size_t size);
 };
 }</pre> 
		
<div class="tablenoborder"><table cellpadding="4" summary="" frame="border" border="1" cellspacing="0" rules="all"><span class="tabledesc">The following table provides additional information on the member
			 of this template class. 
		  </span><thead align="left"> 
				<tr> 
				  <th class="cellrowborder" valign="top" width="33.89830508474576%" id="d23045e152">Member 
				  </th>
 
				  <th class="cellrowborder" valign="top" width="66.10169491525423%" id="d23045e155">Description 
				  </th>
 
				</tr>
</thead>
 
			 <tbody> 
				<tr> 
				  <td class="cellrowborder" valign="top" width="33.89830508474576%" headers="d23045e152 "><span class="keyword">memory_pool(const Alloc &amp;src =
						Alloc())</span> 
				  </td>
 
				  <td class="cellrowborder" valign="top" width="66.10169491525423%" headers="d23045e155 "> 
					 <p>Constructs memory pool with an instance
						of underlying memory allocator of type 
						<samp class="codeph">Alloc</samp> copied
						from 
						<samp class="codeph">src</samp>. Throws 
						<samp class="codeph">bad_alloc</samp>
						exception if runtime fails to construct an instance of the class. 
					 </p>
 
				  </td>
 
				</tr>
 
			 </tbody>
 
		  </table>
</div>
 
	 </div>
 
  </div>


<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong>&nbsp;<a href="../../../../reference/appendices/community_preview_features/scalable_memory_pools.htm">Scalable Memory Pools</a></div>
</div>
<div></div>

</body>
</html>
